<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>登陆</title>
  <link rel="stylesheet" href="./login.css">
  <script src="./jquery-3.6.0.min.js"></script>
</head>
<body>
  <div class="box">
    <div class="pre-box">
      <h1>Welcome</h1>
      <p>Join us!</p>
      <div class="img-box">
        <img src="./img/xp.jpg" alt="">
      </div>
    </div>
    <!--注册-->
    <div class="register-form">
      <div class="title-box">
        <h1>注册</h1>
      </div>
      <div class="input-box">
        <input type="text" placeholder="用户名">
        <input type="text" placeholder="密码">
        <input type="text" placeholder="确认密码">
      </div>
      <div class="btn-box">
        <button>注册</button>
        <p onclick="mySwitch()">已有账号?去注册</p>
      </div>
    </div>
    <!--登陆-->
    <div class="login-form">
      <div class="title-box">
        <h1>登陆</h1>
      </div>
      <div class="input-box">
        <input type="text" placeholder="用户名">
        <input type="text" placeholder="密码">
      </div>
      <div class="btn-box">
        <button>登陆</button>
        <p onclick="mySwitch()">没有账号?去注册</p>
      </div>
    </div>
  </div>

  <script>
    let flag=true
    let mySwitch=()=>{
      if(flag){           //转换属性    位移
        $(".pre-box").css("transform","translateX(100%)")//jq写法 获取到pre-box 给其加上CSS样式
        $(".pre-box").css("background-color","#c9e0ed")
        $("img").attr("src","./img/yxp.jpg")//更改img的src属性值
      }else{
        $(".pre-box").css("transform","translateX(0%)")
        $(".pre-box").css("background-color","#edd4dc")
        $("img").attr("src","./img/xp.jpg")
      }
      flag=!flag
    }
  </script>
</body>
</html>